package com.scada.model.result;

import java.io.Serializable;

/** 
 * @ClassName: RestResponseBean 
 * @Description: TODO
 * @author: 黄胜
 * @date: 2016年12月1日 下午5:03:38  
 */
public class RestResponseBean implements Serializable{
	
	/**
	 * @fieldName: serialVersionUID
	 * @fieldType: long
	 * @Description: TODO
	 */
	private static final long serialVersionUID = -634578990005123642L;

	/**
	 * 响应状态状:成功
	 */
	public static final String RESTYPE_00 = "00";
	/**
	 * 响应状态状:参数错误
	 */
	public static final String RESTYPE_10 = "10";
	/**
	 * 响应状态状:系统内部错误
	 */
	public static final String RESTYPE_11 = "11";
	/**
	 * 响应状态状:连接服务器失败
	 */
	public static final String RESTYPE_12 = "12";
	/**
	 * 响应状态状:业务逻辑错误
	 */
	public static final String RESTYPE_20 = "20";
	
	private Object Data;
	
	//每页显示条数
	private Integer pageSize = 10;
	
	//总条数 
	private Integer count = 0;
	
	//页数
	private int Pages;
	
	private String TypeName;
	
	//回传信息
	private String msg;
	
	private String resType;
	
	private RestResponseBean(){
		
	}
	
	public static RestResponseBean getRestResponseBean(){
		return new RestResponseBean();
	}
	
	public Object getData() {
		return Data;
	}

	public void setData(Object data) {
		Data = data;
	}

	public int getPages() {
		return Pages;
	}

	private void setPages(int pages) {
		Pages = pages;
	}

	public String getTypeName() {
		return TypeName;
	}

	public void setTypeName(String typeName) {
		TypeName = typeName;
	}
	
	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public String getResType() {
		return resType;
	}

	public void setResType(String resType) {
		this.resType = resType;
	}

	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
		setPages(calculationPages(count));
	}

	private Integer calculationPages(Integer count){
		return count / this.pageSize + (count % this.pageSize == 0?0:1);
	}
	
	public void parameterError(){
		this.resType=RestResponseBean.RESTYPE_10;
		this.msg="参数错误";
	}
	
	public void systemError(){
		this.resType=RestResponseBean.RESTYPE_11;
		this.msg="系统内部错误";
	}
	
	public void connectionFailed(){
		this.resType=RestResponseBean.RESTYPE_12;
		this.msg="服务连接失败";
	}
	
	public void businessLogicError(String errorMsg){
		this.resType=RestResponseBean.RESTYPE_20;
		this.msg=errorMsg;
	}
	
	public void success(){
		this.resType=RestResponseBean.RESTYPE_00;
		this.msg="成功";
	}
	
	public void otherTips(String msg){
		
		this.resType=RestResponseBean.RESTYPE_20;
		this.msg=msg;
	}

}
